home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / pascal / tvtool2.zip / TVDIALOG.INT < prev    next >
Text File  |  1993-07-20  |  12KB  |  431 lines

  1. UNIT TvDialog;
  2. {$B+}
  3. {$X+}
  4. {$V-}
  5.  
  6. {$I TVDEFS.INC}
  7.  
  8. INTERFACE
  9.  
  10.  
  11. USES
  12.   Dos,
  13.   TvObject, TvConst, TvString, TvType,
  14.   {$IFDEF USE_NEW_FILE_DIALOG}
  15.   StdDlg,
  16.   {$ENDIF}
  17.   App, Dialogs, Drivers, Memory, MsgBox, Objects, Views;
  18.  
  19.  
  20. CONST
  21.   BarChar       : Char = '▒';
  22.   BarFillChar   : Char = '█';
  23.  
  24.  
  25. CONST
  26.   Buttons       : Array[0..3] of String[8] =
  27.                     ('~Y~es', '~N~o', 'O~K~', '~C~ancel');
  28.   Commands      : Array[0..3] of Word =
  29.                     (cmYes, cmNo, cmOK, cmCancel);
  30.   Titles        : Array[0..3] of String[11] =
  31.                     ('Warning', 'Error', 'Information', 'Confirm');
  32.  
  33.  
  34. CONST
  35.   mfMessageLine  = $1000;
  36.   mfPauseButton  = $2000;
  37.   mfPauseCancel  = mfPauseButton + mfCancelButton;
  38.   mfOKPauseCancel= mfOKCancel + mfPauseButton;
  39.  
  40.  
  41. CONST
  42.   vlCurrent = $0001;
  43.   vlPrev    = $0002;
  44.   vlNext    = $0003;
  45.   vlMin     = $0004;
  46.   vlMax     = $0005;
  47.   vlListMax = $0006;
  48.   vlListMin = $0007;
  49.  
  50.  
  51. {$IFDEF USE_NEW_FILE_DIALOG}
  52. TYPE
  53.   PSearchRec = ^TSearchRec;   {why isn't this public in StdDlg?}
  54.   DriveLetters  = 'A'..'Z';
  55.   DriveSet      = Set of DriveLetters;
  56. {$ENDIF}
  57.  
  58. TYPE
  59.   PbxRunDialog  = ^TbxRunDialog;
  60.   TbxRunDialog  = Object(TDialog)
  61.     Msg     : PStaticText;
  62.     RunState: Word;
  63.     pfFlags : Word;
  64.     BtnRow  : Byte;
  65.     SButton : PButton;
  66.     CButton : PButton;
  67.  
  68.     Constructor Init(var Bounds   : TRect;
  69.                          ATitle   : TTitleStr;
  70.                          AMessage : String;
  71.                          AOptions : Word;
  72.                          ButtonRow: Byte);
  73.     Constructor Load(var S: TStream);
  74.     Procedure   ChangeMessage(AMessage : String);
  75.     Function    Execute: Word;                            Virtual;
  76.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  77.     Procedure   Process;                                  Virtual;
  78.     Procedure   Store(var S: TStream);
  79.   end;
  80.  
  81.  
  82.   PbxPercentDialog  = ^TbxPercentDialog;
  83.   TbxPercentDialog  = Object(TbxRunDialog)
  84.     Total   : LongInt;
  85.     Count   : LongInt;
  86.     Step    : Word;
  87.     Pct     : PStaticText;
  88.     Bar     : PStaticText;
  89.  
  90.     Constructor Init(ATitle   : TTitleStr;
  91.                      AMessage : String;
  92.                      ATotal   : LongInt;
  93.                      AOptions : Word
  94.                     );
  95.     Constructor Load(var S: TStream);
  96.     Procedure   Increment;
  97.     Procedure   IncrementBy(AStep : Word);
  98.     Procedure   Store(var S: TStream);
  99.   end;
  100.  
  101.  
  102.   PbxPrintDialog  = ^TbxPrintDialog;
  103.   TbxPrintDialog  = Object(TbxRunDialog)
  104.     Constructor Init(ATitle   : TTitleStr;
  105.                      AMessage : String;
  106.                      AOptions : Word
  107.                     );
  108.   end;
  109.  
  110.  
  111.   PbxLinkedLine = ^TbxLinkedLine;
  112.   TbxLinkedLine = Object(TInputLine)
  113.     LinkEvent : Word;
  114.  
  115.     Constructor Init(var Bounds : TRect;
  116.                          AMaxLen: Integer;
  117.                          EventCode : Word);
  118.     Constructor Load(var S: TStream);
  119.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  120.     Procedure   Store(var S: TStream);
  121.   end;
  122.  
  123.  
  124.   PbxLinkedBox  = ^TbxLinkedBox;
  125.   TbxLinkedBox  = Object(TListBox)
  126.     LinkEvent : Word;
  127.  
  128.     Constructor Init(var Bounds     : TRect;
  129.                          ANumCols   : Word;
  130.                          AScrollBar : PScrollBar;
  131.                          EventCode  : Word);
  132.     Constructor Load(var S: TStream);
  133.     Procedure   FocusItem(Item : Integer);                Virtual;
  134.     Procedure   Store(var S: TStream);
  135.   end;
  136.  
  137.  
  138.   PbxMessageDialog  = ^TbxMessageDialog;
  139.   TbxMessageDialog  = Object(TDialog)
  140.     SList   : TbxUnsortedStringCollection;
  141.     DOptions: Word;
  142.  
  143.     Constructor Init(AOptions : Word);
  144.     Procedure   AddMessage(St : String);
  145.     Function    Execute: Word;                            Virtual;
  146.   end;
  147.  
  148.  
  149.   PbxListBox  = ^TbxListBox;
  150.   TbxListBox  = Object(TListbox)
  151.     Function  GetText(Item  : Integer;
  152.                       MaxLen: Integer): String;           Virtual;
  153.   end;
  154.  
  155.  
  156.   PbxCheckListBox = ^TbxCheckListBox;
  157.   TbxCheckListBox = Object(TbxListBox)
  158.     Procedure GetSelectSet(var ASet : TbxByteSet);
  159.     Function  GetText(Item  : Integer;
  160.                       MaxLen: Integer): String;           Virtual;
  161.     Procedure HandleEvent(var Event: TEvent);             Virtual;
  162.     Function  IsSelected(Item : Integer): Boolean;        Virtual;
  163.     Procedure SelectItem(Item : Integer);                 Virtual;
  164.     Procedure SetSelectSet(ASet : TbxByteSet);
  165.   end;
  166.  
  167.  
  168.   PbxPairedListBox  = ^TbxPairedListBox;
  169.   TbxPairedListBox  = Object(TbxListBox)
  170.     Procedure SelectItem(Item : Integer);                 Virtual;
  171.     Procedure HandleEvent(var Event : TEvent);            Virtual;
  172.   end;
  173.  
  174.  
  175.   PbxPairedStrListBox  = ^TbxPairedStrListBox;
  176.   TbxPairedStrListBox  = Object(TbxPairedListBox)
  177.     Function  GetText(Item  : Integer;
  178.                       MaxLen: Integer): String;           Virtual;
  179.   end;
  180.  
  181.  
  182.   PbxVListBox  = ^TbxVListBox;
  183.   TbxVListBox  = Object(TListBox)
  184.     AtMin : Boolean;
  185.     AtMax : Boolean;
  186.  
  187.     Constructor Init(Bounds     : TRect;
  188.                      ANumCols   : Word;
  189.                      AHScrollBar: PScrollBar;
  190.                      AVScrollBar: PScrollBar);
  191.     Constructor Load(var S: TStream);
  192.     Function    FillByPage(Forward : Boolean): Integer;   Virtual;
  193.     Function    FillFrom(FromTop : Boolean): Integer;     Virtual;
  194.     Procedure   FocusItem(Item : Integer);                Virtual;
  195.     Function    GetItem(ACommand : Word): PObject;        Virtual;
  196.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  197.     Function    Lookup(P : PObject): Boolean;             Virtual;
  198.     Function    MatchItem(P : PObject): Boolean;          Virtual;
  199.     Procedure   NewList(AList: PCollection);              Virtual;
  200.     Function    PageSize : Integer;                       Virtual;
  201.     Procedure   SetCommandState(Enable : Boolean);
  202.   end;
  203.  
  204.  
  205.   {$IFDEF USE_NEW_FILE_DIALOG}
  206.   PbxFileCollection = ^TbxFileCollection;
  207.   TbxFileCollection = object(TFileCollection)
  208.     Function Compare(Key1, Key2: Pointer): Integer;       Virtual;
  209.   end;
  210.  
  211.  
  212.   PbxFileList = ^TbxFileList;
  213.   TbxFileList = object(TFileList)
  214.     Constructor Init(var Bounds     : TRect;
  215.                          AWildCard  : PathStr;
  216.                          AScrollBar : PScrollBar);
  217.  
  218.     Procedure   HandleEvent(var Event: TEvent);           Virtual;
  219.     Procedure   FocusItem(Item: Integer);                 Virtual;
  220.  
  221.     { **************************************************
  222.       NOTE: The following method must be made virtual in
  223.       the TFileList object in the file STDDLG.PAS unit.
  224.       At line # 101 add a "virtual" declaration.
  225.       ************************************************** }
  226.     Procedure   ReadDirectory(AWildCard : PathStr);       Virtual;
  227.   end;
  228.  
  229.  
  230.   PbxDriveList = ^TbxDriveList;
  231.   TbxDriveList = object(TbxFileList)
  232.     Constructor Init(var Bounds     : TRect;
  233.                          AScrollBar : PScrollBar);
  234.     Procedure   GetDrives(var Drives : DriveSet);
  235.     Procedure   ReadDirectory(AWildCard : PathStr);       Virtual;
  236.     Function    GetKey(var S : String): Pointer;          Virtual;
  237.   end;
  238.  
  239.  
  240.   PbxFileInputLine = ^TbxFileInputLine;
  241.   TbxFileInputLine = object(TFileInputLine)
  242.     Procedure HandleEvent(var Event : TEvent);            Virtual;
  243.   end;
  244.  
  245.  
  246.   PbxFileInfoPane = ^TbxFileInfoPane;
  247.   TbxFileInfoPane = object(TFileInfoPane)
  248.     Procedure   Draw;                                     Virtual;
  249.   end;
  250.  
  251.  
  252.   PbxDirectoryInfoPane = ^TbxDirectoryInfoPane;
  253.   TbxDirectoryInfoPane = object(TView)
  254.     Constructor Init(var Bounds: TRect);
  255.     Function    GetPalette: PPalette;                     Virtual;
  256.     Procedure   HandleEvent(var Event: TEvent);           Virtual;
  257.     Procedure   Draw;                                     Virtual;
  258.   end;
  259.  
  260.  
  261.   PbxFileDialog = ^TbxFileDialog;
  262.   TbxFileDialog = object(TFileDialog)
  263.     DriveList : PbxDriveList;
  264.  
  265.     Constructor Init(AWildCard  : TWildStr;
  266.                      ATitle     : String;
  267.                      InputName  : String;
  268.                      AOptions   : Word;
  269.                      HistoryId  : Byte);
  270.  
  271.     { **************************************************
  272.       NOTE: In TFileDialog in the unit STDDLG.PAS the
  273.       method ReadDirectory must be made PUBLIC.
  274.       At line # 152 remove the "private" declaration.
  275.       ************************************************** }
  276.   end;
  277.   {$ENDIF}
  278.  
  279.  
  280. { TvDialog registration procedure }
  281.  
  282. Procedure RegisterTVDialog;
  283.  
  284.  
  285. { Stream Registration Records }
  286.  
  287. CONST
  288.   RbxRunDialog: TStreamRec = (
  289.     ObjType : 5050;
  290.     VmtLink : Ofs(TypeOf(TbxRunDialog)^);
  291.     Load    : @TbxRunDialog.Load;
  292.     Store   : @TbxRunDialog.Store
  293.   );
  294.  
  295.  
  296. CONST
  297.   RbxPercentDialog: TStreamRec = (
  298.     ObjType : 5051;
  299.     VmtLink : Ofs(TypeOf(TbxPercentDialog)^);
  300.     Load    : @TbxPercentDialog.Load;
  301.     Store   : @TbxPercentDialog.Store
  302.   );
  303.  
  304.  
  305. CONST
  306.   RbxPrintDialog: TStreamRec = (
  307.     ObjType : 5052;
  308.     VmtLink : Ofs(TypeOf(TbxPrintDialog)^);
  309.     Load    : @TbxPrintDialog.Load;
  310.     Store   : @TbxPrintDialog.Store
  311.   );
  312.  
  313.  
  314. CONST
  315.   RbxLinkedLine: TStreamRec = (
  316.     ObjType : 5053;
  317.     VmtLink : Ofs(TypeOf(TbxLinkedLine)^);
  318.     Load    : @TbxLinkedLine.Load;
  319.     Store   : @TbxLinkedLine.Store
  320.   );
  321.  
  322.  
  323. CONST
  324.   RbxLinkedBox: TStreamRec = (
  325.     ObjType : 5054;
  326.     VmtLink : Ofs(TypeOf(TbxLinkedBox)^);
  327.     Load    : @TbxLinkedBox.Load;
  328.     Store   : @TbxLinkedBox.Store
  329.   );
  330.  
  331.  
  332. CONST
  333.   RbxListBox: TStreamRec = (
  334.     ObjType : 5055;
  335.     VmtLink : Ofs(TypeOf(TbxListBox)^);
  336.     Load    : @TbxListBox.Load;
  337.     Store   : @TbxListBox.Store
  338.   );
  339.  
  340.  
  341. CONST
  342.   RbxCheckListBox: TStreamRec = (
  343.     ObjType : 5056;
  344.     VmtLink : Ofs(TypeOf(TbxCheckListBox)^);
  345.     Load    : @TbxCheckListBox.Load;
  346.     Store   : @TbxCheckListBox.Store
  347.   );
  348.  
  349.  
  350. CONST
  351.   RbxPairedListBox: TStreamRec = (
  352.     ObjType : 5057;
  353.     VmtLink : Ofs(TypeOf(TbxPairedListBox)^);
  354.     Load    : @TbxPairedListBox.Load;
  355.     Store   : @TbxPairedListBox.Store
  356.   );
  357.  
  358. CONST
  359.   RbxPairedStrListBox: TStreamRec = (
  360.     ObjType : 5058;
  361.     VmtLink : Ofs(TypeOf(TbxPairedstrListBox)^);
  362.     Load    : @TbxPairedStrListBox.Load;
  363.     Store   : @TbxPairedStrListBox.Store
  364.   );
  365.  
  366. CONST
  367.   RbxVListBox: TStreamRec = (
  368.     ObjType : 5059;
  369.     VmtLink : Ofs(TypeOf(TbxVListBox)^);
  370.     Load    : @TbxVListBox.Load;
  371.     Store   : @TbxVListBox.Store
  372.   );
  373.  
  374. {$IFDEF USE_NEW_FILE_DIALOG}
  375. CONST
  376.   RbxFileCollection: TStreamRec = (
  377.     ObjType : 5060;
  378.     VmtLink : Ofs(TypeOf(TbxFileCollection)^);
  379.     Load    : @TbxFileCollection.Load;
  380.     Store   : @TbxFileCollection.Store
  381.   );
  382.  
  383. CONST
  384.   RbxFileList: TStreamRec = (
  385.     ObjType : 5061;
  386.     VmtLink : Ofs(TypeOf(TbxFileList)^);
  387.     Load    : @TbxFileList.Load;
  388.     Store   : @TbxFileList.Store
  389.   );
  390.  
  391. CONST
  392.   RbxDriveList: TStreamRec = (
  393.     ObjType : 5062;
  394.     VmtLink : Ofs(TypeOf(TbxDriveList)^);
  395.     Load    : @TbxDriveList.Load;
  396.     Store   : @TbxDriveList.Store
  397.   );
  398.  
  399. CONST
  400.   RbxFileInputLine: TStreamRec = (
  401.     ObjType : 5063;
  402.     VmtLink : Ofs(TypeOf(TbxFileInputLine)^);
  403.     Load    : @TbxFileInputLine.Load;
  404.     Store   : @TbxFileInputLine.Store
  405.   );
  406.  
  407. CONST
  408.   RbxFileInfoPane: TStreamRec = (
  409.     ObjType : 5064;
  410.     VmtLink : Ofs(TypeOf(TbxFileInfoPane)^);
  411.     Load    : @TbxFileInfoPane.Load;
  412.     Store   : @TbxFileInfoPane.Store
  413.   );
  414.  
  415. CONST
  416.   RbxDirectoryInfoPane: TStreamRec = (
  417.     ObjType : 5065;
  418.     VmtLink : Ofs(TypeOf(TbxDirectoryInfoPane)^);
  419.     Load    : @TbxDirectoryInfoPane.Load;
  420.     Store   : @TbxDirectoryInfoPane.Store
  421.   );
  422.  
  423. CONST
  424.   RbxFileDialog: TStreamRec = (
  425.     ObjType : 5066;
  426.     VmtLink : Ofs(TypeOf(TbxFileDialog)^);
  427.     Load    : @TbxFileDialog.Load;
  428.     Store   : @TbxFileDialog.Store
  429.   );
  430. {$ENDIF}
  431.